{% load dv_filters %}
{% load i18n %}
{% get_current_language as CURRENT_LANGUAGE_CODE %}
{% get_language_info for CURRENT_LANGUAGE_CODE as CURRENT_LANGUAGE %}
{% get_language_info_list for LANGUAGES as languages %}

{% if languages|length > 1 and user.is_authenticated %}
<li class="dropdown">
    <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">{{ CURRENT_LANGUAGE.name_local|title }}<span class="caret"></span></a>
    <ul class="dropdown-menu">
        {% for language in languages %}
          {% if language.code != CURRENT_LANGUAGE_CODE %}
            <li><form id="setlang-{{ language.code }}" class="language-selector" action="{% url 'set_language' %}" method="post">
                {% csrf_token %}
                <input name="next" type="hidden" value="{{ request|setlang:language.code }}" />
                <input name="language" type="hidden" value="{{ language.code }}" />
                <button class="btn btn-link btn-block" type="submit" title="{{ language.name_local|title }}">{{ language.name_local|title }}</button>
            </form></li>
          {% endif %}
        {% endfor %}
    </ul>
</li>
{% endif %}
